import { Modal } from 'antd'

import { HsAdminTable } from '@hs-admin/base-components'

import { useState, forwardRef, memo, useImperativeHandle } from 'react'

const Information = (props: any, ref: any) => {
  const { columns, data, maxHeight, title } = props

  const [isModalOpen, setIsModalOpen] = useState(false)

  const showModal = () => {
    setIsModalOpen(true)
  }

  const handleCancel = () => {
    setIsModalOpen(false)
  }

  useImperativeHandle(
    ref,
    () => {
      return {
        showModal
      }
    },
    []
  )

  return (
    <Modal title={title} open={isModalOpen} onCancel={handleCancel} footer={false} width="800px">
      <HsAdminTable
        id="J-supply-chain-bid-number-table"
        rowKey="id"
        bordered={true}
        scroll={{ x: 500, y: maxHeight }}
        columns={columns}
        dataSource={data}
        pagination={false}
      />
    </Modal>
  )
}
export default memo(forwardRef(Information))
